package com.ph.irp.base.measureunitgroup.service.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.ph.exception.PHException;
import com.ph.irp.base.measureunitgroup.dao.PBaseMeasureUnitGroupDAO;
import com.ph.irp.base.measureunitgroup.service.PBaseMeasureUnitGroupService;
import com.ph.irp.dto.MeasureDTO;
import com.ph.irp.model.PBaseMeasuregroup;
import com.ph.irp.model.PBaseMeasureunit;

/**
 * The Class PBaseMeasureUnitGroupServiceImpl.
 * 
 * @author SongYandong song.yandong@phinfoservices.com
 * @version 1.0 <br>
 *          Copyright (C), 2009, SongYandong <br>
 *          This program is protected by copyright laws. <br>
 *          Program Name: PBaseMeasureUnitGroupServiceImpl.java<br>
 *          Date:2009-10-27
 */
public class PBaseMeasureUnitGroupServiceImpl implements
		PBaseMeasureUnitGroupService {

	/** The group dao. */
	private PBaseMeasureUnitGroupDAO groupDaoProxy;

	public PBaseMeasureUnitGroupDAO getGroupDaoProxy() {
		return groupDaoProxy;
	}

	public void setGroupDaoProxy(PBaseMeasureUnitGroupDAO groupDaoProxy) {
		this.groupDaoProxy = groupDaoProxy;
	}

	/**
	 * 添加
	 * 
	 */
	public void addMeasureGroup(PBaseMeasuregroup model) throws Throwable {

		this.groupDaoProxy.addMeasureGroupUnit(model);
	}

	/**
	 * 查询所有
	 * 
	 */
	public List<PBaseMeasuregroup> getMeasureGroupAll() throws Throwable {
		return groupDaoProxy.getMeasureGroupAll();
	}

	/**
	 * 查询计量单位组byName
	 * 
	 */
	public List<PBaseMeasuregroup> getMeasureGroupByName(String name)
			throws Throwable {
		List<PBaseMeasuregroup> groupList = new ArrayList<PBaseMeasuregroup>();

		if (!name.equals("")) {
			groupList = this.groupDaoProxy.getMeasureGroupByName(name);
		}

		return groupList;
	}

	/**
	 * 查询计量单位组byCode
	 * 
	 */
	public List<PBaseMeasuregroup> getMeasureGroupByCode(String code)
			throws Throwable {
		List<PBaseMeasuregroup> groupList = new ArrayList<PBaseMeasuregroup>();

		if (!code.equals("")) {
			groupList = this.groupDaoProxy.getMeasureGroupByCode(code);
		}

		return groupList;
	}

	/**
	 * 查询计量单位组byNameAndCode
	 * 
	 */
	public List<PBaseMeasuregroup> getMeasureGroupByNameAndCode(String name,
			String code) throws Throwable {
		List<PBaseMeasuregroup> groupList = new ArrayList<PBaseMeasuregroup>();

		if (!code.equals("") && !name.equals("")) {
			groupList = this.groupDaoProxy.getMeasureGroupByNameAndCode(name,
					code);
		}
		return groupList;
	}

	/**
	 * 查询计量单位组byID
	 * 
	 */
	@Override
	public PBaseMeasuregroup getMeasureGroupById(int measureGroupId)
			throws Throwable {
		return groupDaoProxy.getMeasureGroupById(measureGroupId);
	}

	/**
	 * 修改
	 * 
	 */
	@Override
	public void updaeMeasureGroup(PBaseMeasuregroup model) throws Throwable {
		this.groupDaoProxy.updateMeasureGroupUnit(model);
	}

	/**
	 * 删除
	 * 
	 */
	@Override
	public void deleteMeasureGroup(Object[] id) throws Throwable {
		for (int i = 0; i < id.length; i++) {
			groupDaoProxy.deleteMeasureGroup(Integer.valueOf((String) id[i]));
		}
	}

}
